//
//  WBEmotionPopView.m
//  新浪微博项目
//
//  Created by neng on 15/12/23.
//  Copyright (c) 2015年 neng. All rights reserved.
//

#import "WBEmotionPopView.h"
#import "WBEmotion.h"
#import "WBEmotionButton.h"

@interface WBEmotionPopView ()

@property (weak, nonatomic) IBOutlet WBEmotionButton *emotionBtn;
@end

@implementation WBEmotionPopView

+ (instancetype)popView
{
    return [[[NSBundle mainBundle] loadNibNamed:@"WBEmotionPopView" owner:nil options:nil] lastObject];
}



- (void)showFromView:(WBEmotionButton *)btn
{
    self.emotionBtn.emotion = btn.emotion;
    
    //弹出放大镜添加到window上
    UIWindow *window = [[UIApplication sharedApplication].windows lastObject];
    [window addSubview:self];
    
    //转换成对应window的frame
    CGRect frame = [btn convertRect:btn.bounds toView:nil];
    CGFloat centerX = CGRectGetMidX(frame);
    CGFloat centerY = CGRectGetMidY(frame) - self.height / 2;
    //设置popView的位置
    self.center = CGPointMake(centerX, centerY);
}


@end
